package project.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import project.pojo.Course;
import project.pojo.Teacher;

import java.util.List;

/**
 * @version: 1.0
 * @Auther: Ranger
 * @LastEditTime: 2022-05-11 21:25
 */
public interface TeacherMapper {

    /**
     *
     * 判断登入
     * @param id
     * @param password
     * @return
     */
    @Select("select * from teacher where id=#{id} and password=#{password}")
    @ResultMap("TeacherResultMap")
    Teacher judgeLogin(@Param("id") Long id, @Param("password") String password);

    /**
     *
     * 展示老师教的课程
     * @param id
     * @return
     */
    @Select("select id,name,credit,course_time,type,department_name from course where teacher_id=#{id}")
    @ResultMap("CourseResultMap")
    List<Course> showCourseByTeacherId(Long id);

    /**
     *
     * 根据信息查询老师教的课程
     * @param name
     * @param courseTime
     * @param type
     * @return
     */
    List<Course> queryAllByInformation(@Param("name") String name, @Param("courseTime") String courseTime,  @Param("teacherId") Long teacherId,@Param("type") String type);

    /**
     *
     * 老师添加课程
     * @param course
     */
    boolean addCourse(Course course);

    /**
     *
     * 通过老师id查询老师对象
     * @param teacherId
     * @return
     */
    @Select("select * from teacher where id=#{teacherId}")
    @ResultMap("TeacherResultMap")
    Teacher selectTeacherByTeacherId(Long teacherId);

    /**
     *
     * 根据课程id删除一个课程
     * @param courseId
     * @return
     */
    @Delete("delete from course where id=#{courseId}")
    @ResultMap("CourseResultMap")
    boolean deleteCourseSingle(@Param("courseId") Long courseId);

    /**
     *
     * 根据课程id修改课程
     * @param course
     * @return
     */
    boolean updateCourseById(Course course);

    /**
     *
     * 根据课程ids删除课程
     * @param courseIds
     * @return
     */
    boolean deleteCourseByIds(@Param("courseIds") Long[] courseIds);

    /**
     *
     * 修改老师信息
     * @param teacher
     * @return
     */
    boolean updateTeacherInfo(Teacher teacher);

    /**
     *
     * 修改老师密码
     * @param id
     * @param password
     */
    boolean updateTeacherPassword(@Param("id") Long id, @Param("password") String password);
}
